import axios from 'axios'
import { Message } from 'element-ui'
const _axios = axios.create({
  baseURL: process.env.VUE_APP_BASE_API
})
_axios.interceptors.request.use(
  (config) => {
    return config
  },
  (error) => {
    return Promise.reject(error)
  }
)
_axios.interceptors.response.use(
  (res) => {
    if (res.data.success) {
      return res.data
    } else {
      Message.error(res.data.message)
      return Promise.reject(res.data.message)
    }
  },
  (error) => {
    return Promise.reject(error)
  }
)
export default _axios
